/*
 * Pattern.h
 *
 *  Created on: 2013. 10. 8.
 *      Author: the2
 */

#ifndef PATTERN_H_
#define PATTERN_H_

#include <stddef.h>

namespace pattern {

template <typename T>
class Singleton
{
protected:
	Singleton() {}

	virtual ~Singleton()
	{
		pInstance = NULL;
	}

public:
	static T* GetInstance()
	{
		if(NULL == pInstance)
			pInstance = new T;
		return pInstance;
	}

private:
	Singleton(const Singleton&);
	Singleton& operator=(const Singleton&);
	static	T *pInstance;
};

template <typename T>
T *Singleton<T>::pInstance = NULL;

} /*pattern*/


#endif /* PATTERN_H_ */
